<?php

namespace app\index\model;

use app\admin\model\PohtoInstitution;
use think\Model;
use think\model\concern\SoftDelete;

class PohtoUser extends Model
{
    use SoftDelete;
    protected $name = 'car_photo_user'; //表名
    protected $autoWriteTimestamp = true;
    // 定义时间戳字段名
    protected $dateFormat = 'Y/m/d H:i:s';
    protected $createTime = 'create_at';
    protected $updateTime = 'update_at';
    protected $deleteTime='delete_at';

    public function institutionName()
    {
        return $this->hasOne(PohtoInstitution::class, 'id', 'institution_id')->bind([
            'institution_name' => 'name',
            'institution_avatar' => 'cover',
            'institution_avatar_id' => 'cover_id'
        ]);
    }

    public function photoNum()
    {
        return $this->hasOne(PhotoList::class, 'author_id', 'id');
    }

    public function photoTen()
    {
        return $this->hasMany(PhotoList::class, 'author_id', 'id')->limit(10);
    }

    public function photo()
    {
        return $this->hasOne(PhotoList::class, 'author_id', 'id');
    }
}